import 'dart:convert';


import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../constant.dart';


class AMapNaviController {
  
  final MethodChannel mapNaviChannel;

  AMapNaviController.withId(int id) : mapNaviChannel = MethodChannel('$AMAP_CHANNEL_NAME/amap_navi$id');

  ///导航设置起点终点
  ///LatLng location = new LatLng(latitude: Utils.location.latitude, longitude: Utils.location.longitude);
  ///参数:  Map<String, String> map = {
  ///       "location": json.encode(location),
  ///       "endLatlng": json.encode(endLatlng)
  ///       };
  Future<dynamic> navigation(Map<String, dynamic> map) async {
    debugPrint('方法:navigation dart端参数:-> $map');
    //TODO 在安卓上返回的是bool ios上返回的是String 所以使用了dynamic
    var invoke =   await mapNaviChannel.invokeMethod("navigation", map);
    print("invoke:::${invoke.runtimeType}");
    return invoke;
  }
  ///导航停止
  Future<bool> stopNavi() async {
    return await mapNaviChannel.invokeMethod("stopNavi");
  }
}